﻿using System;
using System.Collections.Generic;
using System.Text;
using Pixysoft.Tools;

namespace Pixysoft.Framework.Configurations.Core
{
    class XmlNotEqualConstraintProperty<T> : XmlConstraintProperty<T>, IXmlConstraintProperty
    {
        public XmlNotEqualConstraintProperty(string elementName,
            string propertyName, T propertyValue, string format)
            : base(elementName, propertyName, propertyValue, format)
        {
        }

        #region IXmlConstraintProperty 成员

        public bool Meets(string value)
        {
            if (string.IsNullOrEmpty(value))
                return false;

            T tvalue = default(T);

            if (!ParserHelper.TryParse<T>(value, out tvalue, Format))
                return false;

            if (tvalue.Equals(PropertyValue))
                return false;

            return true;
        }

        #endregion
    }
}
